package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.request.ProjectEntryRequest;
import com.nbsaas.boot.project.data.entity.Project;
import com.nbsaas.boot.project.data.entity.ProjectEntry;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;

/**
 * 请求对象转换成实体对象
 */

public class ProjectEntryEntityConvert implements Converter<ProjectEntry, ProjectEntryRequest> {

    @Override
    public ProjectEntry convert(ProjectEntryRequest source) {
        ProjectEntry result = new ProjectEntry();
        BeanDataUtils.copyProperties(source, result);
        if (source.getProject() != null) {
            Project project = new Project();
            project.setId(source.getProject());
            result.setProject(project);
        }
        return result;
    }
}

